$.fn.extend({
ajax_load: function(uri_path, query, callback) {    load_html(this, "__url__/" + uri_path, query, callback); }
});
$.extend({
ajax_post: function(uri_path, query, callback) { post_request("__url__/" + uri_path, query, callback); }
});


function load_html(divobj, url, query, callback)
{
 	var params = {};
    params[gadgets.io.RequestParameters.CONTENT_TYPE] = 
        gadgets.io.ContentType.TEXT;
    gadgets.io.makeRequest(url + "?rnd=" + Math.random() + "&" + query, function(xhr) {
        divobj.html(xhr.text);
        callback();
        gadgets.window.adjustHeight();
    }
    , params);
}

function post_request(url, query, callback)
{
 	var params = {};
    params[gadgets.io.RequestParameters.CONTENT_TYPE] = 
        gadgets.io.ContentType.TEXT;
    params[gadgets.io.RequestParameters.METHOD] = 
        gadgets.io.MethodType.POST;
    var query_string = gadgets.io.encodeValues(query);
    gadgets.io.makeRequest(url + "?rnd=" + Math.random() + "&" + query_string, function(xhr) {
        callback(xhr.text, 'success');
    }
    , params);
}


function notify()
{
    gadgets.window.adjustHeight();
}

function ack()
{
	up();
}

function user()
{
	return wave.getViewer().getId().replace("@googlewave.com", "");
}
